﻿using CNKI.TPI.Web.Admin.Model;
using CNKI.TPI.Web.Search.Model;
using KNet.Data.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.TPI.Web.Admin.IBLL
{
    /// <summary>
    /// 跨库发布设置Service
    /// </summary>
    public interface IMultiDBPublishService
    {
        /// <summary>
        /// 保存跨库分类
        /// </summary>
        /// <returns></returns>
        bool SavetDBClass(DBCLASS obj, string m);
        /// <summary>
        /// 删除跨库分类
        /// </summary>
        /// <returns></returns>
        bool DeleteDBClass(string code);

        /// <summary>
        /// 更新数据库的分类信息
        /// </summary>
        /// <param name="classCode"></param>
        /// <param name="configList"></param>
        /// <returns></returns>
        bool UpdateDBConfig(string classCode, IList<DBCONFIG> configList);
        /// <summary>
        /// 获取所有已经发布的数据库列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetPublishDBList(bool visible=true);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbID"></param>
        /// <returns></returns>
        IList<SYS_CMS_US_FIELDMAP> GetDBMapInfo(int dbID);
        /// <summary>
        /// 根据查询条件获取数据库分页数据
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndexNow"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDBMappingList(int pageSize, int pageIndexNow, string type, string name, out int count);
        /// <summary>
        /// 删除SYS_CMS_US_FIELDMAP
        /// </summary>
        /// <param name="fieldmap"></param>
        /// <returns></returns>
        bool DeleteFIELDMAP(SYS_CMS_US_FIELDMAP fieldmap);

/// <summary>
        /// 获取公共映射字段
/// </summary>
/// <returns></returns>
        IList<SYS_CMS_US_FIELD> GetUSFiled();
        /// <summary>
        /// 获取数据字段
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE_FIELD> GetDBFiledByDbCode(string code);
        /// <summary>
        /// 保存映射字段
        /// </summary>
        /// <param name="dbfieldID"></param>
        /// <param name="usfield"></param>
        /// <param name="dbid"></param>
        /// <param name="flage"></param>
        /// <param name="sysid"></param>
        /// <returns></returns>
        int MappingSave(string dbfieldID, string usfield, string dbid, string flage, string sysid);
        /// <summary>
        /// 根据公共字段名称，获取数据
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        IList<SYS_CMS_US_FIELD> GetUSFieldByName(string name);
        /// <summary>
        /// 保存设置的跨库字段 FieldType：1=检索字段 2=排序字段 3=概览字段
        /// </summary>
        /// <returns></returns>

        bool SavetUsField(IList<DBUSFIELD> fieldList, int filedtype);
        /// <summary>
        /// 保存数据库相关信息
        /// </summary>
        /// <param name="dbobj"></param>
        /// <param name="list"></param>
        /// <param name="fieldstr"></param>
        bool DealDataBaseInfo(SYS_CMS_DATABASE dbobj, IList<SYS_CMS_DATABASE_FIELD> list, string fieldstr);
       /// <summary>
        /// 删除数据库及字段
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool DelDbAndFields(string id);

          /// <summary>
        /// 根据数据名称，和编码判断数据库是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="dbcode"></param>
        /// <param name="sysid">0代表新增时判断 反之代表修改</param>
        /// <returns></returns>
        int IsExistDB(string name, string dbcode, int sysid);
    }
}
